package org.ezplatform.office.forum.util.sensitiveword;

import java.util.List;
import java.util.Map;

/** 
* @author 作者: wujs
* @version 创建时间：2019年3月9日 上午10:52:03 
* 类说明 
*/
public class SensitiveUtils {
	
	/**
    * 替换敏感词
    * 
    * @param list 敏感词集合
    * @param replaceCon 替换内容
    * @param matchType 1-替换最小敏感词、；2-替换所有敏感词
    * @param replaceChar
    * @return
    */
	public static String replaceSensitiveWord(Map sensitiveWordMap,String replaceCon,int matchType,String replaceChar){
		SensitiveWordEngine.sensitiveWordMap = sensitiveWordMap;
		String reStr = SensitiveWordEngine.replaceSensitiveWord(replaceCon,matchType,replaceChar);
		return reStr;
	}
	
	public static Map initKeyWord(List<String> list){
		if(list == null || list.isEmpty()){
			return null;
		}
		// 初始化敏感词库对象
		SensitiveWordInit sensitiveWordInit = new SensitiveWordInit();
		// 构建敏感词库
		Map sensitiveWordMap = sensitiveWordInit.initKeyWord(list);
		// 传入SensitivewordEngine类中的敏感词库
		return sensitiveWordMap;
	}
}
